<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>state</title>
  </head>
  <body>
    <div id="test"></div>
    <div id="test1"></div>
    <div id="test2"></div>

    <script
      src="https://unpkg.com/react@16/umd/react.development.js"
      crossorigin
    ></script>
    <script
      src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"
      crossorigin
    ></script>
    <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
    <script type="text/babel"></script>
  </body>
  <script type="text/babel">
    class Person extends React.Component {
      // state = { name: "tom", age: 18, sex: "女", age: 16 };
      render() {
        const { name, age, sex } = this.props;
        return (
          <ul>
            <li>姓名:{name}</li>
            <li>性别:{sex}</li>
            <li>年龄:{age + 1}</li>
          </ul>
        );
      }
    }
    //渲染组件
    ReactDOM.render(
      <Person name="tom" age={18} sex="男" />,
      document.getElementById("test")
    );
    ReactDOM.render(
      <Person name="lina" age={19} sex="女" />,
      document.getElementById("test1")
    );
    const p = { name: "老刘", age: 18, sex: "女" };
    // ReactDOM.render(
    //   <Person name={p.name} age={p.age} sex={p.sex} />,
    //   document.getElementById("test2")
    // );
    ReactDOM.render(<Person {...p} />, document.getElementById("test2"));
  </script>
</html>
